<template>
	<!-- 下拉刷新组件 -->
  <view>
    <scroll-view ref="scrollView" :scroll-y="true" @touchstart="handleTouchStart" @touchend="handleTouchEnd">
      <slot></slot>
    </scroll-view>
  </view>
</template>

<script>
export default {
  methods: {
    handleTouchStart(e) {
      this.startY = e.changedTouches[0].clientY;
    },
    handleTouchEnd(e) {
      const endY = e.changedTouches[0].clientY;
      if (endY - this.startY > 50) {
        // 下拉大于50px时触发下拉刷新操作
        this.$emit('refresh');
      }
    }
  }
};
</script>
